import { Body, Get, Inject, Post, Provide, Query } from '@midwayjs/core';
import {
  CoolController,
  BaseController,
} from '@cool-midway/core';
import { HelpInfoEntity } from '../../entity/info';
import { HelpInfoService } from '../../service/info';

/**
 * 帮助信息管理
 */
@Provide()
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: HelpInfoEntity,
  service: HelpInfoService,
  listQueryOp: {
    fieldEq: ['type', 'status'],
    keyWordLikeFields: ['title'],
    addOrderBy: {
      orderNum: 'ASC',
      createTime: 'ASC',
    },
  },
})
export class AdminHelpInfoController extends BaseController {
  @Inject()
  helpInfoService: HelpInfoService;

  @Get('/getAllTypes', { summary: '获取所有类型的帮助信息' })
  async getAllTypes() {
    return this.ok(await this.helpInfoService.getAllTypes());
  }

  @Get('/getByType', { summary: '根据类型获取帮助信息' })
  async getByType(@Query('type') type: number) {
    return this.ok(await this.helpInfoService.getByType(type));
  }
}